<!--移动签批->公文详情->发电抄阅->index-->
<template>
  <view>
    <van-tabs color="#1989fa" title-active-color="#1989fa" animated swipeable @change="onChange">
      <van-tab title="公文详情" name="gwxq">
        <detail ref="detail" :proInstId="proInstId" :detailObj1="detailObj1" :otherDetail="otherDetail"
                @showFenfaSheet="showFenfaSheet"></detail>
      </van-tab>
      <van-tab title="版式稿纸" name="bsgz">
        <read :detailObj1="detailObj1" :proInstId="proInstId" :otherDetail="otherDetail"></read>
      </van-tab>
      <van-tab title="流转过程" name="lzgc" :key='2'>
        <docProcess :dataList="dataList"></docProcess>
      </van-tab>
    </van-tabs>
    <records @refreshBtnGroup="refreshBtnGroup" :showRecords="showRecords" @closeRecords="closeRecords"
             :paramObject="paramObject"></records>
    <trans ref="trans" :proInstId="proInstId" @refreshBtnGroup="refreshBtnGroup" :showTrans="showTrans"
           @closeTrans="closeTrans" :paramObject="paramObject" :detailObject="detailObj1.detailObj"></trans>
    <distribute ref="distribute" @refreshBtnGroup="refreshBtnGroup" :showDistribute="showDistribute"
                @closeDistribute="closeDistribute" :paramObject="paramObject"
                :detailObject="detailObj1.detailObj"></distribute>
    <fb ref="fb" @refreshBtnGroup="refreshBtnGroup" :showFb="showFb" @closeFb="closeFb" :paramObject="paramObject"
        :gwTitle="circuTitle"></fb>

    <more :showShare="showShare" @closeShare="closeShare" :options="barList.slice(4)"></more>
    <fenfa ref="fenfa" :showFenfa="showFenfa" @closeFenfaSheet="closeFenfaSheet"></fenfa>
    <div style="height: 5rem;" v-if="fromType != 'search'">
      <van-tabbar v-model="active">
        <van-tabbar-item v-for="(item,index) in barList" :key="index" v-if="index < 4" :name="item.name"
                         @click="onClick(item.operation)">
          <span>{{ item.value }}</span>
          <template #icon="props">
            <img :src="props.active ? item.iconTab.active : item.iconTab.inactive"/>
          </template>
        </van-tabbar-item>
      </van-tabbar>
    </div>
  </view>
</template>

<script>
import detail from 'pages/caac/components/sendMsgCopyDoc/compo-detail';
import docProcess from 'pages/caac/components/sendMsgCopyDoc/compo-process';
import read from 'pages/caac/components/sendMsgCopyDoc/compo-read';
import records from 'pages/caac/components/common/compo-records';
import trans from 'pages/caac/components/sendMsgCopyDoc/compo-trans';
import more from 'pages/caac/components/sendMsgCopyDoc/compo-more';
import distribute from 'pages/caac/components/sendMsgCopyDoc/compo-distribute';
import fb from 'pages/caac/components/common/compo-fbgl';
import fenfa from 'pages/caac/components/common/compo-fenfa';

export default {
  components: {
    detail,
    docProcess,
    records,
    trans,
    more,
    read,
    distribute,
    fb,
    fenfa
  },
  onLoad: async function (option) {
    await this.$onLaunched //解決bug：执行完onLaunch后再执行页面onLoad
    this.userInfo = this.cache.get('userInfo')//从缓存获取用户信息
    //从地址栏获取proInstId
    this.proInstId = option.proInstId
    //fromType==search，说明是从公文搜索页跳转过来，隐藏相关操作按钮
    this.fromType = option.from
    if (this.proInstId != undefined && this.proInstId != '') {
      this.getCaacDetail(this.proInstId)//通过proInstId获取详情
      this.findfbdept(this.proInstId)//司局分办处室
      this.getCaacOpinion(this.proInstId)//获取意见
    }
  },
  created() {

  },
  //文件编辑保存后返回到首页就重新获取文件及附件
  onShow(){
    //延迟调用，防止文件过大PC端没保存上就获取
    setTimeout(() => {
      if(this.util.isNotEmpty(this.extendIdForRelate)){
        this.getCaacBody(this.extendIdForRelate)//获取正文
        this.getCaacAttachment(this.extendIdForRelate)//获取附件
        this.getRelation(this.extendIdForRelate)//获取附加公文
      }
    }, 800)
  },
  data() {
    return {
      fromType: '',//fromType==search，说明是从公文搜索页跳转过来，隐藏相关操作按钮
      //记录对应的tab页数据是否已加载
      gwxqFlag: true,
      bsgzFlag: true,
      lzgcFlag: true,
      extendIdForRelate: '',
      gwSercet: {},//公文秘书，调退公文秘书接口用参数
      userInfo: {},//当前登录用户信息，目前先从缓存中获取
      proInstId: '',
      tuiSms: [],//退司秘书所需参数，调用 listNextActivities 接口获得
      tuiJms: [],//退局文秘书所需参数，调用listNextActivities接口获得
      tuiGongWen: [],	// 处室秘书 退公文秘书所需参数，调用listNextActivities接口获得
      endGongWen: [],//结束公文所需参数，调用listNextActivities接口获得
      fwId: '',//发文id
      active: '',
      showEdit: false,
      showRecords: false,
      showTrans: false,
      showShare: false,
      showDistribute: false,// 批示分送
      showIssuance: false,//签发
      barList: [],
      //公文详情
      detailObj1: {
        detailObj: null,//详情
        detailBody: null,//正文
        detailAttachment: null,//附件
        opinion: null,//意见
        optionBtn01: null,//获取签批功能菜单所需要的参数
        optionBtn02: null,//获取签批功能菜单所需要的参数
        optionBtn: null,//签批功能菜单,根据optionBtn01和optionBtn02返回的参数作为请求参数
      },
      dataList: {
        docProcess: {},//流转过程
        signProcess: [],//会签件
      },

      options: [],//更多操作
      //获取签批功能的接口里有
      paramObject: {
      },
      buttonArr: [],    // 要显示的功能按钮
      circuTitle: '',     // 标题
      showFb: false,      // 分办按钮
      otherDetail: {
        fbDeptList: [],// 已分办处室
      },
      showFenfa: false,//分发组件
      opinionId:'',//需要删除的意见ID
    };
  },
  watch: {},

  mounted() {
    //处理页面弹出层初始化
    this.active = 'gwxq'
    this.showEdit = false
    this.showRecords = false
    this.showTrans = false
    this.showShare = false
    this.showIssuance = false
  },
  methods: {
    //显示分发组件
    showFenfaSheet() {
      this.showFenfa = true
    },
    //关闭分发组件
    closeFenfaSheet(userInfo) {
      this.$refs.detail.initParam(userInfo)
      this.showFenfa = false
    },
    //tab 点击事件
    onChange(itemTitle) {
      if (itemTitle == 'gwxq') {//公文详情
        if (this.gwxqFlag) {
          this.getCaacDetail(this.proInstId)
        }
      } else if (itemTitle == 'bsgz') {//版式稿纸
        if (this.bsgzFlag) {
          //TODO 加载版式稿纸
        }
      } else if (itemTitle == 'lzgc') {//流转过程
        if (this.lzgcFlag) {
          this.getCaacDocProcess(this.proInstId)
          this.getListChildSubOperationLogs(this.proInstId)
        }
      }
    },
    //关闭修改公文要素
    closeEdit(showEdit) {
      this.showEdit = false
    },
    //关闭填写意见
    closeRecords(showRecords) {
      this.showRecords = false
    },
    //关闭流转
    closeTrans(showTrans) {
      this.showTrans = false
    },
    //关闭更多操作
    closeShare(item) {
      this.showShare = false
      this.btnFunction(item)
    },
    // 关闭批示分发
    closeDistribute(item) {
      this.showDistribute = false
    },
    //关闭签发
    closeIssuance(showIssuance) {
      this.showIssuance = false
    },

    //点击tabbar
    onClick(item) {
      this.btnFunction(item)
    },
    //下边菜单点击功能
    btnFunction(item) {
      //修改公文要素
      if (item == 'xggwys') {
        this.showEdit = true
        this.$refs.edit.editGw(this.proInstId);//调用子组件的方法
      }
      //填写意见
      if (item == 'addReviews') {
        this.showRecords = true
      }
      //流转
      if (item == 'generalMove' || item == 'complete') {
        this.showTrans = true
        //调用子组件的方法
        this.$refs.trans.getSelectPerson(this.proInstId, this.detailObj1.detailObj.drafterId)
      }
      //批示分送
      if (item == 'psfs') {
        this.showDistribute = true
      }
      //更多操作
      if (item == 'more') {

        this.showShare = true
      }
      //结束公文
      if (item == 'endProcess') {
        this.endProcess()
      }
      if (item == 'goOutProInst') {
        this.endProcess()
      }

      //会签管理
      if (item == 'huiqianManagement') {
        //跳转到会签页面
        uni.navigateTo({
          url: "/pages/caac/sendMsg/countersign?proInstId=" + this.proInstId + "&fwId=" + this.extendIdForRelate
        })
      }

      // //退公文秘书
      // if(item == 'tcsms'){
      // 	this.tuiGwmsConfirm()
      // 	// this.$toast('退公文秘书')
      // }
      if (item === 'returnToChuMs' || item === 'liuzhuanTuimishu' || item === 'returnSecretary' || item === 'szsliuzhuanTuimishu') {
        this.tuiGwmsConfirm(item)
      }
      //签发
      if (item == 'review_QianFa') {
        this.showIssuance = true

      }
      //作废
      if (item == 'cancelGw') {
        this.cancelGwConfirm()
      }
      if (item == 'review_TongYi') {
        this.opinionType('1')//1-同意，2-已阅
      }
      if (item == 'review_YiYue') {
        this.opinionType('2')//1-同意，2-已阅
      }
      if (item == 'review_YiYue_PB') {
        this.opinionType('3')//1-同意，2-已阅
      }
      //分办管理
      if (item == 'sendFb') {
        this.showFb = true
        this.circuTitle = this.detailObj1.detailObj.title
      }
      //结束并发送
      if (item == 'endProcessAndSend') {
        this.endProcessAndSendConfirm()
      }
      //结束不发送
      if (item == 'endProcessAndNotSend') {
        this.endProcessAndNotSendConfirm()
      }
      //本单位会签完毕hqwb
      if (item == 'hqwb') {
        this.hqwbConfirm()
      }
      //清除意见
      if (item == 'deleteOpinion') {
        this.deleteOpinionConfirm()
      }
    },

    // 获取要显示的按钮
    async getButtonsData(proInstId) {
      let _this = this
      await _this.$http({
        url: _this.$http.adornUrl(`/caac/oa/app/getButtonsData`),
        method: 'get',
        params: _this.$http.adornParams({
          'systemKey': _this.userInfo.systemKey,//固定值
          'systemFlag': _this.userInfo.systemFlag,//固定值
          'proInstId': proInstId
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.buttonArr = data.data.buttons
        }
      })
    },

    // 关闭分办窗口
    closeFb() {
      this.showFb = false
    },

    //作废
    cancelGwConfirm() {
      this.$dialog.confirm({
        title: '系统提示',
        message: '您确定要操作吗?',
      })
          .then(() => {
            // on confirm
            this.cancelGw()

          })
          .catch(() => {
            // on cancel
          });
    },
    //作废公文
    cancelGw() {
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/workflow/abortApplictionController/abortApplication`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          data: this.$http.adornData({
            'configId': _this.paramObject.configId,
            'proDirId': _this.paramObject.proDirId,//发文详情返回的proInstId
            'proInstId': _this.paramObject.proInstId,
            'actInstId': _this.paramObject.actInstId,//
            'workitemId': _this.paramObject.workitemId,
            'gwId': this.fwId,
            'title': this.detailObj1.detailObj.title
          }),
        }
      }).then(({data}) => {
        console.log("作废结果-->>: " + JSON.stringify(data));
        if (data.code == 200) {
          _this.$toast("操作成功")
          //作废后还需调另外两个接口
          _this.canceGwUpdateDraftStatus()
          _this.canceGwDeleteWordBiz()
          uni.redirectTo({
            url: '/pages/caac/send/signListdb?topShow=dsqdb'
          })
        } else {
          _this.$toast(data.message + ' code:' + data.code)
        }

      })

    },
    //作废-更新状态
    canceGwUpdateDraftStatus() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/fw/updateDraftStatus`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'id': this.proInstId
        })
      }).then(({data}) => {
        console.log("作废UpdateDraftStatus()--->data: " + JSON.stringify(data));
      })

    },
    //作废-更新状态
    canceGwDeleteWordBiz() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/fw/deleteWordBiz`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'fwId': this.fwId
        })
      }).then(({data}) => {
        console.log("作废DeleteWordBiz()-->data: " + JSON.stringify(data));
      })

    },
    //同意或已阅1-同意，2-已阅
    opinionType(type) {
      console.log("this.paramObject: " + JSON.stringify(this.paramObject));
      this.$dialog.confirm({
        title: '系统提示',
        message: '确定要操作吗?',
      }).then(() => {
        // on confirm
        if (this.util.isNotEmpty(this.paramObject)) {
          if (type == '1') {//1-同意review_TongYi
            this.message = '同意'
            this.opiniontype = 'dbJldReview'
            this.saveopinion()
          } else if(type == '2'){//review_YiYue
            if (this.paramObject.actDefId != 'otherTask'){
              if(this.paramObject.actDefId == 'jld' || this.paramObject.actDefId == 'jldsh'){
                this.opiniontype = "dbJldReview";
              }else {
                this.opiniontype = "dbBlbmReview";
              }
            } else if (this.paramObject.actDefId == 'otherTask') {
              this.$http({
                url: this.$http.adornUrl(`/caac/wfm/CustomActivityController/initOperationAuthority`),
                method: 'get',
                params: this.$http.adornParams({
                  'systemKey': this.userInfo.systemKey,//固定值
                  'systemFlag': this.userInfo.systemFlag,//固定值
                  'proInstId': this.paramObject.proInstId,
                  'canGotoSpecialDraft': true
                })
              }).then(({data}) => {
                if (data.currentActivity.indexOf('jld') > -1) {
                  this.opiniontype = "dbJldReview";
                } else {
                  this.opiniontype = "dbBlbmReview";
                }
              })
            }
            this.message = '已阅'
            this.saveopinion()
          }else if(type == '3'){//review_YiYue_PB
            if(this.paramObject.actDefId == 'jld' || this.paramObject.actDefId == 'jldsh'){
              this.opiniontype = "dbJldReview"
            }else {
              this.opiniontype = "dbPbbmReview"
            }
            this.message = '已阅'
            this.saveopinion()
          }
        }


      })
          .catch(() => {
            // on cancel
          });

    },
    //填写意见接口
    saveopinion() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/approval/saveopinion`),
        method: 'post',
        params:{
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
        },
        data: this.$http.adornData({
          'proInstId': _this.paramObject.proInstId,//发文详情返回的proInstId
          'workItemId': _this.paramObject.workitemId,//
          'actInstId': _this.paramObject.actInstId,//
          'opiniontype': _this.opiniontype,
          'opinion': _this.message,
          'isApproval': '1',//核稿状态，默认传1
        })
      }).then(({data}) => {
        console.log("填写意见返回：data-->: " + JSON.stringify(data));
        if (data.code == 200) {
          this.$toast('意见填写成功')
          this.refreshBtnGroup(true)
        } else {
          this.$toast(data.message + ' code:' + data.code)
        }

      })
    },
    //结束并发送
    endProcessAndSendConfirm() {
      this.$dialog.confirm({
        title: '系统提示',
        message: '确定转机要处发送吗?',
      })
          .then(() => {
            // on confirm
            this.endProcessAndSend()

          })
          .catch(() => {
            // on cancel
          });
    },
    endProcessAndSend() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/hbglj/gwfd/sendfd/` + this.fwId),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          //"sendType":"1", //这个值结束并发送传1   结束不发送传2
          _this.endProcessSendOrNot('1')
        }
        console.log("正文--------------------------: " + JSON.stringify(_this.detailObj1.detailBody));
      })

    },
    //结束不发送
    endProcessAndNotSendConfirm() {
      this.$dialog.confirm({
        title: '系统提示',
        message: '确定仅结束不转机要处发送吗?',
      })
          .then(() => {
            // on confirm
            this.endProcessAndNotSend()

          })
          .catch(() => {
            // on cancel
          });
    },
    endProcessAndNotSend() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/hbglj/gwfd/notsendfd/` + this.fwId),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          //"sendType":"1", //这个值结束并发送传1   结束不发送传2
          _this.endProcessSendOrNot('2')
        }
        console.log("正文--------------------------: " + JSON.stringify(_this.detailObj1.detailBody));
      })
    },
    //"sendType":"1", //这个值结束并发送传1   结束不发送传2
    endProcessSendOrNot(sendType) {
      let fdForm = this.detailObj1.detailObj
      this.$set(fdForm, 'sendType', sendType)//给fdFomr 添加属性并赋值：sendType
      //结束公文、本单位会签完毕
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          data: this.$http.adornData({
            fdForm: fdForm,//详情
            wfmData: {
              'configId': _this.paramObject.configId,
              'proDirId': _this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': _this.paramObject.actDefId,//
              'proInstId': _this.paramObject.proInstId,
              'actInstId': _this.paramObject.actInstId,//
              'workitemId': _this.paramObject.workitemId,
              'nextActivities': _this.endGongWen
            },
          })
        }
      }).then(({data}) => {
        console.log("结束公文sendType data-->>: " + JSON.stringify(data));
        if (data.code == 200) {
          _this.$toast('操作成功')
          uni.redirectTo({
            url: '/pages/caac/send/signListdb?topShow=dsqdb'
          })

        } else {
          _this.$toast(data.message + ' code:' + data.code)
        }

      })
    },
    //本单位会签完毕
    hqwbConfirm() {
      this.$dialog.confirm({
        title: '系统提示',
        message: '您确定要操作吗?',
      })
          .then(() => {
            // on confirm
            this.endProcess()//本单位会签完毕和结束公文是同一个接口

          })
          .catch(() => {
            // on cancel
          });
    },
    //结束公文确认弹框
    endProcess() {
      this.$dialog.confirm({
        confirmButtonColor: '#1989fa',
        title: '系统提示',
        message: '确认要结束公文吗?',
      }).then(() => {
        this.saveOpinionAndSendWithoutSelectUser('end')
      }).catch(() => {
        // on cancel
      });
    },
    //获取发电抄阅待办详情数据
    getCaacDetail(proInstId) {
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/doc/fd/proInstId/` + proInstId),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        console.log("发电抄阅公文详情: " + JSON.stringify(data));
        if (data.code == 200) {
          //根据字典code获取字典
          _this.detailObj1.detailObj = data.data
          _this.fwId = data.data.fdId
          _this.extendIdForRelate = data.data.annexId
          _this.getCaacBody(_this.extendIdForRelate)//获取正文
          _this.getCaacAttachment(_this.extendIdForRelate)//获取附件
          _this.getRelation(_this.extendIdForRelate)//获取附加公文
          _this.openwfneededdata(_this.fwId, proInstId)

          this.gwxqFlag = false //请求成功后置为false，防止tab切换重新获取数据
        }

      })
    },

    //获取正文数据
    getCaacBody(extendIdForRelate) {
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/maintext/proInstId/` + extendIdForRelate),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          _this.detailObj1.detailBody = data.data
        }
        console.log("正文--------------------------: " + JSON.stringify(_this.detailObj1.detailBody));
      })
    },

    //获取附件数据
    getCaacAttachment(extendIdForRelate) {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/attachmentupload/attachmentinfoOrderByNew`),
        method: 'get',
        params: this.$http.adornParams({
          'bizId': extendIdForRelate,
          'attachTypeId': 'pageBody_uploadFile',
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          _this.detailObj1.detailAttachment = data.data
        }
        console.log("附件: " + JSON.stringify(_this.detailObj1.detailAttachment));
      })
    },

    //获取意见
    getCaacOpinion(proInstId) {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/approval/approvalwrite`),
        method: 'get',
        params: this.$http.adornParams({
          'proInstId': proInstId,
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          if (data.data != null) {
            _this.detailObj1.opinion = data.data
          }
        }
        console.log("意见: " + JSON.stringify(data));
      })
    },
    //获取附加公文
    getRelation(extendIdForRelate) {
      // proInstId = 'f9525d014c5348fb866daca4879ae905'//TODO 暂时写死
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/mhjComponent/relationfile/relation`),
        method: 'get',
        params: this.$http.adornParams({
          'docId': extendIdForRelate,
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          if (data.data != null) {
            _this.detailObj1.relation = data.data
          }
        }
        console.log("附加公文: " + JSON.stringify(data));
      })
    },

    //获取流转过程
    getCaacDocProcess(proInstId) {
      const _this = this
      this.$httploading({
        // url: this.$http.adornUrl(`/caac/oa/mhjcomponent/processtrack/flowController/listoperationlogs`),
        url: this.$http.adornUrl(`/caac/oa/component/workflow/workflowController/listProInstIdOperationLogs`),
        method: 'post',
        params: this.$http.adornParams({
          'proInstId': proInstId,
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        console.log("流转过程------------------: " + JSON.stringify(data));
        if (data.code == 200) {
          _this.dataList.docProcess = data.data
          this.lzgcFlag = false
        }

      })
    },
    //获取子流转过程
    getListChildSubOperationLogs(proInstId) {
      const _this = this
      this.$http({/// /caac/oa/mhjcomponent/processtrack/flowController/listoperationlogs
        url: this.$http.adornUrl(`/caac/oa/component/workflow/workflowController/listChildSubOperationLogs?systemKey=` + this.userInfo.systemKey + `&systemFlag=` + this.userInfo.systemFlag),
        method: 'post',
        params: this.$http.adornParams({
          'proInstId': proInstId,
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        console.log("子流转过程data: " + JSON.stringify(data));
        if (data.code == 200) {
          _this.dataList.signProcess = data.data
        }
        console.log("_this.dataList: " + JSON.stringify(_this.dataList));
      })
    },

    //获取签批功能菜单optionBtn01
    openwfneededdata(fwId, proInstId) {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/comm/comm/openwfneededdata`),
        method: 'get',
        params: this.$http.adornParams({
          'id': fwId,//发文详情返回的fwId
          'proInstId': proInstId,//发文详情返回的proInstId
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          _this.detailObj1.optionBtn01 = data.data
          _this.paramObject = data.data
          console.log("签批功能菜单optionBtn01: " + JSON.stringify(data.data));
          _this.getRoleTypesAndActInst(data.data.configId, proInstId)
        }

      })
    },

    //获取签批功能菜单optionBtn02
    getRoleTypesAndActInst(configId, proInstId) {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/getRoleTypesAndActInst`),
        method: 'post',
        params: this.$http.adornParams({
          'proInstId': proInstId,//发文详情返回的proInstId
          'configId': configId,//openwfneededdata()返回的configId
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          _this.detailObj1.optionBtn02 = data.data
          console.log("签批功能菜单optionBtn02: " + JSON.stringify(data.data));
          _this.initActivity()

        }

      })
    },
    /**
     * 子页面流转后调用此方法刷新功能按钮
     * @param {Object} item Boolean值
     */
    refreshBtnGroup(item) {
      this.getCaacDetail(this.proInstId)
      this.getCaacOpinion(this.proInstId)//重新获取意见
      setTimeout(()=>{
        this.findfbdept(this.proInstId)//司局分办处室
      }, 500)
    },
    //获取签批功能菜单
    async initActivity() {
      // 获取要显示的按钮
      await this.getButtonsData(this.proInstId)
      const _this = this
      let option01 = this.detailObj1.optionBtn01
      let option02 = this.detailObj1.optionBtn02.actInstList[0] //TODO 次处返回了数组格式，需和pc端确认
      await this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/initActivity`),
        method: 'post',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'data': this.$http.adornData({
            'configId': option01.configId,//openwfneededdata()返回的configId
            'configCode': option01.configCode,
            'proDirId': option01.proDirId,
            'actDefId': option01.actDefId,
            'wfmRoleTypes': option02.wfmRoleTypes,
            'proInstId': option01.proInstId,
            'actInstId': option01.actInstId,
            'workitemId': option01.workitemId,
            'wfmInitPageType': 'running',
            'bizId': option01.bizId
          }),

        })
      }).then(({data}) => {
        console.log("data---->>: " + JSON.stringify(data));
        if (data.code == 200) {
          _this.detailObj1.optionBtn = data.data
          let operations = data.data.qualifiedOperations
          // console.log(operations);
          _this.barList = [] //重置为空
          if (operations != null && operations.length > 0) {
            //TODO 还需判断其他类型的按钮
            for (let i = 0; i < operations.length; i++) {
              //修改公文要素
              if (operations[i].operation == 'xggwys') {
                _this.barList.push({
                  name: '修改公文要素',
                  operation: 'xggwys',
                  icon: 'static/imgs/icon/icon-xggwys.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-xggwys-active.png',
                    inactive: 'static/imgs/icon/icon-xggwys.png'
                  },
                  value: operations[i].operationName,
                  sort: 10
                })
              }
              //填写意见
              if (operations[i].operation == 'addReviews') {
                _this.barList.push({
                  name: '填写意见',
                  operation: 'addReviews',
                  icon: 'static/imgs/icon/icon-opinion.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-opinion-active.png',
                    inactive: 'static/imgs/icon/icon-opinion.png'
                  },
                  value: operations[i].operationName,
                  sort: 1
                })
              }
              //流转
              if (operations[i].operation == 'generalMove') {
                _this.barList.push({
                  name: '流转',
                  operation: 'generalMove',
                  icon: 'static/imgs/icon/icon-transfer.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-transfer-active.png',
                    inactive: 'static/imgs/icon/icon-transfer.png'
                  },
                  value: operations[i].operationName,
                  sort: 3
                })
              }
              if (operations[i].operation == 'complete') {
                _this.barList.push({
                  name: '流转',
                  operation: 'complete',
                  icon: 'static/imgs/icon/icon-transfer.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-transfer-active.png',
                    inactive: 'static/imgs/icon/icon-transfer.png'
                  },
                  value: operations[i].operationName,
                  sort: 3
                })
              }
              //结束公文
              if (operations[i].operation == 'endProcess') {
                _this.barList.push({
                  name: '结束公文',
                  operation: 'endProcess',
                  icon: 'static/imgs/icon/icon-finished.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-finished-active.png',
                    inactive: 'static/imgs/icon/icon-finished.png'
                  },
                  value: operations[i].operationName,
                  sort: 11
                })
              }
              if (operations[i].operation == 'goOutProInst') {
                _this.barList.push({
                  name: '结束公文',
                  operation: 'goOutProInst',
                  icon: 'static/imgs/icon/icon-finished.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-finished-active.png',
                    inactive: 'static/imgs/icon/icon-finished.png'
                  },
                  value: operations[i].operationName,
                  sort: 11
                })
              }
              //会签管理
              if (operations[i].operation == 'huiqianManagement') {
                _this.barList.push({
                  name: '会签管理',
                  operation: 'huiqianManagement',
                  icon: 'static/imgs/icon/icon-sign.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-sign-active.png',
                    inactive: 'static/imgs/icon/icon-sign.png'
                  },
                  value: operations[i].operationName,
                  sort: 4
                })
              }
              if (operations[i].operation == 'returnToChuMs' || operations[i].operation === 'liuzhuanTuimishu'
                  || operations[i].operation === 'returnSecretary' || operations[i].operation === 'szsliuzhuanTuimishu') {
                _this.barList.push({
                  name: operations[i].operationName,
                  operation: operations[i].operation,
                  icon: 'static/imgs/icon/icon-tuigwms.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-tuigwms-active.png',
                    inactive: 'static/imgs/icon/icon-tuigwms.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //签发
              if (operations[i].operation == 'review_QianFa') {
                _this.barList.push({
                  name: '签发',
                  operation: 'review_QianFa',
                  icon: 'static/imgs/icon/icon-qianfa.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-qianfa-active.png',
                    inactive: 'static/imgs/icon/icon-qianfa.png'
                  },
                  value: operations[i].operationName,
                  sort: 8
                })
              }
              //批示分送
              if (operations[i].operation == 'psfs') {
                _this.barList.push({
                  name: '批示分送',
                  operation: 'psfs',
                  icon: 'static/imgs/icon/icon-handover.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-handover-active.png',
                    inactive: 'static/imgs/icon/icon-handover.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //作废
              if (operations[i].operation == 'cancelGw') {
                _this.barList.push({
                  name: '作废',
                  operation: 'cancelGw',
                  icon: 'static/imgs/icon/icon-invalid.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-invalid-active.png',
                    inactive: 'static/imgs/icon/icon-invalid.png'
                  },
                  value: operations[i].operationName,
                  sort: 12
                })
              }
              //结束并发送
              if (operations[i].operation == 'endProcessAndSend') {
                _this.barList.push({
                  name: '结束并发送',
                  operation: 'endProcessAndSend',
                  icon: 'static/imgs/icon/icon-finishsend.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-finishsend-active.png',
                    inactive: 'static/imgs/icon/icon-finishsend.png'
                  },
                  value: operations[i].operationName,
                  sort: 5
                })
              }
              //结束不发送
              if (operations[i].operation == 'endProcessAndNotSend') {
                _this.barList.push({
                  name: '结束不发送',
                  operation: 'endProcessAndNotSend',
                  icon: 'static/imgs/icon/icon-finishunsend.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-finishunsend-active.png',
                    inactive: 'static/imgs/icon/icon-finishunsend.png'
                  },
                  value: operations[i].operationName,
                  sort: 6
                })
              }
              //本单位会签完毕
              if (operations[i].operation == 'hqwb') {
                _this.barList.push({
                  name: '本单位会签完毕',
                  operation: 'hqwb',
                  icon: 'static/imgs/icon/icon-agree.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-agree-active.png',
                    inactive: 'static/imgs/icon/icon-agree.png'
                  },
                  value: operations[i].operationName,
                  sort: 9
                })
              }
              //同意
              if (operations[i].operation == 'review_TongYi') {
                _this.barList.push({
                  name: '同意',
                  operation: 'review_TongYi',
                  icon: 'static/imgs/icon/icon-agree.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-agree-active.png',
                    inactive: 'static/imgs/icon/icon-agree.png'
                  },
                  value: operations[i].operationName,
                  sort: 6
                })
              }
              //已阅
              if (operations[i].operation == 'review_YiYue') {
                _this.barList.push({
                  name: '已阅',
                  operation: 'review_YiYue',
                  icon: 'static/imgs/icon/icon-yy.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-yy-active.png',
                    inactive: 'static/imgs/icon/icon-yy.png'
                  },
                  value: operations[i].operationName,
                  sort: 7
                })
              }
              //分办管理
              if (operations[i].operation == 'sendFb') {
                _this.barList.push({
                  name: '分办管理',
                  operation: 'sendFb',
                  icon: 'static/imgs/icon/icon-handover.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-handover-active.png',
                    inactive: 'static/imgs/icon/icon-handover.png'
                  },
                  value: operations[i].operationName,
                  sort: 8
                })
              }
              //清除意见
              if (operations[i].operation == 'deleteOpinion') {
                _this.barList.push({
                  name: operations[i].operationName,
                  operation: 'deleteOpinion',
                  icon: 'static/imgs/icon/icon-invalid.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-invalid-active.png',
                    inactive: 'static/imgs/icon/icon-invalid.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }

            }
            // 功能按钮筛选
            if (this.util.isNotEmpty(this.buttonArr)) {
              let newBarList = []
              this.buttonArr.filter((b, index) => this.buttonArr.indexOf(b) === index).forEach((item) => {
                let arr = this.barList.filter(t => t.operation == item)
                if (arr != null && arr.length > 0) {
                  newBarList.push(arr[0])
                }
              })
              this.barList = newBarList
            } else {
              this.barList = []//如果获取到的按钮为空，则置空
            }
            //大于三个添加更多按钮,第四个按钮为更多操作
            if (_this.barList.length > 3) {
              _this.barList.sort((a, b) => a.sort - b.sort)
              let more = {
                name: '更多',
                operation: 'more',
                icon: 'static/imgs/icon/icon-more.png',
                iconTab: {
                  active: 'static/imgs/icon/icon-more-active.png',
                  inactive: 'static/imgs/icon/icon-more.png',
                },
                value: '更多操作',
              }
              _this.barList.splice(3, 0, more);
            }
          }


        } else {
          console.log("出错了: " + JSON.stringify(data));
        }

      })
      await this.showDeleteOpinionBtn()//判断是否显示清除意见按钮
    },

    szsliuzhuanTuimishu() {
      let szsMs
      const deptId = this.userInfo.mainDept.deptId
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/sd/findszsms`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'deptId': deptId
        })
      }).then(({data}) => {
        if (data.code == 200) {
          if (this.util.isNotEmpty(data.data) && this.util.isNotEmpty(data.data.user)) {
            szsMs = data.data.user.userId;
            this.sendWithoutSelectUserSzs(szsMs);
          } else {
            this.$toast('该领导未配置秘书，需配置！')
          }
        } else {
          this.$toast(data.message)
        }

      })
    },

    liuzhuanTuimishu() {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/MhjApplicationController/getJldMsRelate`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
        })
      }).then(({data}) => {
        let msId = ''
        if (data.code == 200) {
          if (this.util.isNotEmpty(data.data)) {
            data.data.forEach((item) => {
              if (this.userInfo.userId == item.ldId) {
                msId = item.msId
              }
              if (this.util.isEmpty(msId)) {
                this.$toast('该领导未配置秘书，需配置！')
              } else {
                this.sendWithoutSelectUserJuld(msId)
              }
            })
          } else {
            this.$toast('该领导未配置秘书，需配置！')
          }
        } else {
          this.$toast("获取秘书失败,code:" + data.code)
        }

      })
    },
    sendWithoutSelectUserSzs(msId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/listNextActivities`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'data': this.$http.adornData({
            'wfmData': {
              'configId': this.paramObject.configId,
              'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': this.paramObject.actDefId,//
              'actInstId': this.paramObject.actInstId,//
              'workitemId': this.paramObject.workitemId,
              'wfmInitPageType': 'running'
            }
          })
        }
      }).then(({data}) => {
        if (this.util.isNotEmpty(data.data.nextActDefIds)) {
          let nextActivity = {};
          let nextActivities = [];
          nextActivities.push(nextActivity);
          this.$httploading({
            url: this.$http.adornUrl(`/caac/wfm/ApplicationController/gotoActivity`),
            method: 'post',
            params: {
              'systemKey': this.userInfo.systemKey,//固定值
              'systemFlag': this.userInfo.systemFlag,//固定值
              data: this.$http.adornData({
                wfmData: {
                  'configId': this.paramObject.configId,
                  'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
                  'actDefId': this.paramObject.actDefId,//
                  'proInstId': this.paramObject.proInstId,
                  'actInstId': this.paramObject.actInstId,//
                  'workitemId': this.paramObject.workitemId,
                  'nextActivities': nextActivity,
                  'formData': {
                    fdForm: this.detailObj1.detailObj,//详情
                  },
                  "gotoResourceIds": "user:" + msId,
                  'gotoActDefId': 'otherTask'
                },
              })
            }
          }).then(({data}) => {
            if (data.code == 200) {
              this.$toast("操作成功")
              // 发送通知
              let messageUserIds = msId;
              let linkUrl = this.configUtil.baseUrl + this.configUtil.basePath + "/#/pages/caac/sendMsgCopy/index?proInstId=" + this.paramObject.proInstId;
              this.lx.sendMessage(this.cache.get("appType"), messageUserIds,
                  this.detailObject.title, "发电抄阅", linkUrl);
              uni.redirectTo({
                url: '/pages/caac/send/signListdb?topShow=dsqdb'
              })
            } else {
              this.$toast(data.message + ' code:' + data.code)
            }

          })
        } else {
          this.$toast("操作失败，获取流程节点信息为空");
        }
      })
    },
    /**
     * 秘书id
     * @param msId
     */
    sendWithoutSelectUserJuld(msId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/listNextActivities`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'data': this.$http.adornData({
            wfmData: {
              'configId': this.paramObject.configId,
              'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': this.paramObject.actDefId,//
              'actInstId': this.paramObject.actInstId,//
              'workitemId': this.paramObject.workitemId,
              'wfmInitPageType': 'running'
            }
          })
        }
      }).then(({data}) => {
        if (this.util.isNotEmpty(data.data.nextActDefIds)) {
          let nextActDefIds = data.data.nextActDefIds
          let nextActivity = {}
          let currentActDefId = this.paramObject.actDefId
          for (var i = 0; i < nextActDefIds.length; i++) {
            if (("jzbgs" === nextActDefIds[i].actDefId && currentActDefId.indexOf("jld") > -1) || ("jzbgszz" === nextActDefIds[i].actDefId && currentActDefId.indexOf("jld") > -1)) {
              nextActivity = nextActDefIds[i];
            }
          }
          nextActivity.participants = "user:" + msId
          let nextActivities = []
          nextActivities.push(nextActivity)
          //退公文秘书
          this.$httploading({
            url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
            method: 'post',
            params: {
              'systemKey': this.userInfo.systemKey,//固定值
              'systemFlag': this.userInfo.systemFlag,//固定值
              'data': this.$http.adornData({
                'fdForm': this.detailObj1.detailObj,//详情
                'wfmData': {
                  'configId': this.paramObject.configId,
                  'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
                  'actDefId': this.paramObject.actDefId,//
                  'proInstId': this.paramObject.proInstId,
                  'actInstId': this.paramObject.actInstId,//
                  'workitemId': this.paramObject.workitemId,
                  'nextActivities': nextActivities
                },
              })
            }
          }).then(({data}) => {
            if (data.code == 200) {
              this.$toast('操作成功')
              // 发送通知
              let messageUserIds = msId;
              let linkUrl = this.configUtil.baseUrl + this.configUtil.basePath + "/#/pages/caac/sendMsgCopy/index?proInstId=" + this.paramObject.proInstId;
              this.lx.sendMessage(this.cache.get("appType"), messageUserIds,
                  this.detailObject.title, "发电抄阅", linkUrl);
              uni.redirectTo({
                url: '/pages/caac/send/signListdb?topShow=dsqdb'
              })
            } else {
              this.$toast(data.message + ' code:' + data.code)
            }

          })
        }

      })
    },
    //获取流转范围
    saveOpinionAndSendWithoutSelectUser(goOutType) {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/listNextActivities`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'data': this.$http.adornData({
            wfmData: {
              'configId': this.paramObject.configId,
              'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': this.paramObject.actDefId,//
              'actInstId': this.paramObject.actInstId,//
              'workitemId': this.paramObject.workitemId,
              'wfmInitPageType': 'running'
            }
          })
        }
      }).then(({data}) => {
        if (data.code == 200) {
          let actType = "";
          let nextActDefIds = data.data.nextActDefIds
          if (nextActDefIds) {
            if (goOutType) {
              actType = goOutType
            }
            for (let i = 0; i < nextActDefIds.length; i++) {
              let nextActivity = nextActDefIds[i]
              if (nextActivity.actType === actType || nextActivity.actDefId === actType) {
                nextActivity.participants = "user:" + this.userInfo.userId
                if (this.util.isNotEmpty(goOutType) && (goOutType === 'jzbgs' || goOutType === 'jzbgszz')) {
                  //获取局秘书
                  this.$http({
                    url: this.$http.adornUrl(`/caac/oa/doc/sd/msuser`),
                    method: 'get',
                    params: this.$http.adornParams({
                      'systemKey': this.userInfo.systemKey,//固定值
                      'systemFlag': this.userInfo.systemFlag,//固定值
                      'userId': this.userInfo.userId
                    })
                  }).then(({data}) => {
                    // {"code":200,"data":{"message":"获取成功！","userId":"2277"},"message":null}
                    if (data.code == 200) {
                      if (this.util.isNotEmpty(data.data)) {
                        nextActivity.participants = "user:" + data.data.userId
                        let nextActivities = []
                        nextActivities.push(nextActivity)
                        //退公文秘书
                        this.$httploading({
                          url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
                          method: 'post',
                          params: {
                            'systemKey': this.userInfo.systemKey,//固定值
                            'systemFlag': this.userInfo.systemFlag,//固定值
                            'data': this.$http.adornData({
                              'fdForm': this.detailObj1.detailObj,//详情
                              'wfmData': {
                                'configId': this.paramObject.configId,
                                'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
                                'actDefId': this.paramObject.actDefId,//
                                'proInstId': this.paramObject.proInstId,
                                'actInstId': this.paramObject.actInstId,//
                                'workitemId': this.paramObject.workitemId,
                                'nextActivities': nextActivities
                              },
                            })
                          }
                        }).then(({data}) => {
                          if (data.code == 200) {
                            this.$toast('操作成功')
                            // 发送通知
                            let messageUserIds = data.data.userId;
                            let linkUrl = this.configUtil.baseUrl + this.configUtil.basePath + "/#/pages/caac/sendMsgCopy/index?proInstId=" + this.paramObject.proInstId;
                            this.lx.sendMessage(this.cache.get("appType"), messageUserIds,
                                this.detailObject.title, "发电抄阅", linkUrl);
                            uni.redirectTo({
                              url: '/pages/caac/send/signListdb?topShow=dsqdb'
                            })
                          } else {
                            this.$toast(data.message + ' code:' + data.code)
                          }

                        })
                      } else {
                        this.$toast('该领导未配置秘书，需配置！')
                      }
                    } else {
                      this.$toast('此领导秘书配置有误！' + data.message)
                    }
                  })
                } else if (this.util.isNotEmpty(goOutType) && goOutType === 'sms') {
                  //获取司秘书
                  this.$http({
                    url: this.$http.adornUrl(`/caac/oa/doc/sd/csmsuser`),
                    method: 'get',
                    params: this.$http.adornParams({
                      'systemKey': this.userInfo.systemKey,//固定值
                      'systemFlag': this.userInfo.systemFlag,//固定值
                    })
                  }).then(({data}) => {
                    if (data.code == 200) {
                      if (this.util.isNotEmpty(data.data)) {
                        nextActivity.participants = "user:" + data.data.userId
                        let nextActivities = []
                        nextActivities.push(nextActivity)
                        //退公文秘书
                        this.$httploading({
                          url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
                          method: 'post',
                          params: {
                            'systemKey': this.userInfo.systemKey,//固定值
                            'systemFlag': this.userInfo.systemFlag,//固定值
                            'data': this.$http.adornData({
                              'fdForm': this.detailObj1.detailObj,//详情
                              'wfmData': {
                                'configId': this.paramObject.configId,
                                'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
                                'actDefId': this.paramObject.actDefId,//
                                'proInstId': this.paramObject.proInstId,
                                'actInstId': this.paramObject.actInstId,//
                                'workitemId': this.paramObject.workitemId,
                                'nextActivities': nextActivities
                              },
                            })
                          }
                        }).then(({data}) => {
                          if (data.code == 200) {
                            this.$toast('操作成功')
                            // 发送通知
                            let messageUserIds = data.data.userId;
                            let linkUrl = this.configUtil.baseUrl + this.configUtil.basePath + "/#/pages/caac/sendMsgCopy/index?proInstId=" + this.paramObject.proInstId;
                            this.lx.sendMessage(this.cache.get("appType"), messageUserIds,
                                this.detailObject.title, "发电抄阅", linkUrl);
                            uni.redirectTo({
                              url: '/pages/caac/send/signListdb?topShow=dsqdb'
                            })
                          } else {
                            this.$toast(data.message + ' code:' + data.code)
                          }

                        })
                      } else {
                        this.$toast('该领导未配置秘书，需配置！')
                      }
                    } else {
                      this.$toast(data.message)
                    }

                  })
                } else {
                  let nextActivities = []
                  nextActivities.push(nextActivity)
                  //退公文秘书
                  this.$httploading({
                    url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
                    method: 'post',
                    params: {
                      'systemKey': this.userInfo.systemKey,//固定值
                      'systemFlag': this.userInfo.systemFlag,//固定值
                      'data': this.$http.adornData({
                        'fdForm': this.detailObj1.detailObj,//详情
                        'wfmData': {
                          'configId': this.paramObject.configId,
                          'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
                          'actDefId': this.paramObject.actDefId,//
                          'proInstId': this.paramObject.proInstId,
                          'actInstId': this.paramObject.actInstId,//
                          'workitemId': this.paramObject.workitemId,
                          'nextActivities': nextActivities
                        },
                      })
                    }
                  }).then(({data}) => {
                    if (data.code == 200) {
                      this.$toast('操作成功')
                      uni.redirectTo({
                        url: '/pages/caac/send/signListdb?topShow=dsqdb'
                      })
                    } else {
                      this.$toast(data.message + ' code:' + data.code)
                    }

                  })
                }

              }
            }
          } else {
            this.$toast("操作失败，获取流程节点信息为空")
          }
        }

      })
    },
    //退公文秘书
    tuiGwmsConfirm(type) {
      this.$dialog.confirm({
        title: '系统提示',
        message: '您确定要操作吗?',
      }).then(() => {
        if (type === 'returnToChuMs') {//退司秘书
          this.saveOpinionAndSendWithoutSelectUser('sms')
        } else if (type === 'returnSecretary') {//退局秘书
          this.saveOpinionAndSendWithoutSelectUser('jzbgs')
        } else if (type === 'liuzhuanTuimishu') {
          this.liuzhuanTuimishu()
        } else if (type === 'szsliuzhuanTuimishu') {
          this.szsliuzhuanTuimishu()
        }
      }).catch(() => {
      });
    },

    //获取司局分办处室
    findfbdept(proInstId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/fb/findfbdept`),
        method: 'get',
        params: {
          'systemKey': this.cache.get('userInfo').systemKey,
          'systemFlag': this.cache.get('userInfo').systemFlag,
          'proInstId': proInstId
        }
      }).then(({data}) => {
        if (data.code == 200) {
          this.otherDetail.fbDeptList = []
          data.data.deptIds.split(',').forEach((item, index) => {
            this.otherDetail.fbDeptList.push({"deptId": item, "deptName": data.data.depts.split('、')[index]})
          })
        }
      })
    },
//判断是否显示清除意见按钮
    async showDeleteOpinionBtn(){
      await this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/approval/findmyopinion`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'proInstId':this.proInstId,
          'workItemId':this.paramObject.workitemId,
          'approver':this.userInfo.userId
        })
      }).then(({data}) => {
        if (data.code == 200) {
          if (this.util.isNotEmpty(data.data)) {
            this.opinionId = data.data.id //要删除的意见id
          }else{
            this.opinionId = ''
            //如果意见为null,则不显示清除意见按钮
            this.barList = this.barList.filter(t => t.operation != 'deleteOpinion' && t.operation != 'more')
            //大于三个添加更多按钮,第四个按钮为更多操作
            if (this.barList.length > 3) {
              this.barList.sort((a, b) => a.sort - b.sort)
              let more = {
                name: '更多',
                operation: 'more',
                icon: 'static/imgs/icon/icon-more.png',
                iconTab: {
                  active: 'static/imgs/icon/icon-more-active.png',
                  inactive: 'static/imgs/icon/icon-more.png',
                },
                value: '更多操作',
              }
              this.barList.splice(3, 0, more);
            }
          }
        } else {
          console.log(data.message)
        }

      })

    },
    //清除意见
    deleteOpinionConfirm(){
      this.$dialog.confirm({
        title: '系统提示',
        message: '您确定要操作吗?',
      }).then(() => {
        this.deleteOpinion()//删除意见
      }).catch(() => {
      });
    },
    //删除意见
    deleteOpinion() {
      if (this.util.isNotEmpty(this.opinionId)) {
        this.$http({
          url: this.$http.adornUrl(`/caac/oa/component/approval`),
          method: 'delete',
          params: this.$http.adornParams({
            'systemKey': this.userInfo.systemKey,//固定值
            'systemFlag': this.userInfo.systemFlag,//固定值
            'opinionId': this.opinionId
          })
        }).then(({data}) => {
          if (data.code == 200) {
            this.$toast("删除意见成功")
            this.refreshBtnGroup('')
          } else {
            this.$toast(data.message)
          }
        })
      }else{
        this.$toast('当前没有可删除的意见!')
      }
    }

  },
};
</script>

<style scoped>

</style>
